package com.nexus.auth.controller;

import com.nexus.core.exception.AuthenicException;
import com.nexus.core.auth.LoginUser;
import com.nexus.core.response.ResponseMessage;
import com.nexus.plugin.security.service.SecurityLoginService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统用户认证接口
 *
 * @Date 2025/7/31 15:02
 * @Author luzhengning
 **/
@Slf4j
@RestController
@RequestMapping("/auth/sys")
public class AuthSysController {

    @Autowired
    private SecurityLoginService securityLoginService;


    @PostMapping("login")
    public ResponseEntity<?> login(@Valid @RequestBody LoginUser loginParam) throws AuthenicException {
        // 获取用户信息
        LoginUser loginUser = securityLoginService.sysLogin(loginParam);
        return ResponseMessage.OK(loginUser);
    }

}
